//
//  JCPlanWebViewController.m
//  JiFengDaRen
//
//  Created by shouhan on 2018/4/4.
//  Copyright © 2018年 陈永发. All rights reserved.
//

#import "JCPlanWebViewController.h"
#import <JavaScriptCore/JavaScriptCore.h>

@interface JCPlanWebViewController ()<UIWebViewDelegate>
@property (nonatomic, strong) UIWebView * webView;

@end

@implementation JCPlanWebViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
   
    self.webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight - KNAVIGATIONBARHEIGHT)];
    [self.webView loadHTMLString:self.url baseURL:nil];
    [self.view addSubview:self.webView];
}


- (void)webViewDidFinishLoad:(UIWebView *)webView
{
    JSContext *content = [self.webView valueForKeyPath:@"documentView.webView.mainFrame.javaScriptContext"];
    
    content[@"closeActivity"] = ^(void) {
        [self.navigationController popViewControllerAnimated:YES];
    };
    NSLog(@"成功");
    
}

- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
    NSLog(@"%@",error.localizedDescription);
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}


@end
